<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>对字符串进行大小写转换</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.mb-convert-case" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_convert_case</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">mb_convert_case</span> &mdash; <span class="dc-title">对字符串进行大小写转换</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.mb-convert-case-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mb_convert_case</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$encoding</code><span class="initializer"> = mb_internal_encoding()</span></span>
  ] ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   对一个 <span class="type"><a href="language.types.string.html" class="type string">string</a></span> 进行大小写转换，转换模式由 <code class="parameter">mode</code> 指定。
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.mb-convert-case-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">str</code></dt>

     <dd>

      <p class="para">
       要被转换的 <span class="type"><a href="language.types.string.html" class="type string">string</a></span>。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">mode</code></dt>

     <dd>

      <p class="para">
       转换的模式。它可以是
       <strong><code>MB_CASE_UPPER</code></strong>、 
       <strong><code>MB_CASE_LOWER</code></strong> 和
       <strong><code>MB_CASE_TITLE</code></strong> 的其中一个。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">encoding</code></dt>

     <dd>

      <p class="para"><code class="parameter">encoding</code>
参数为字符编码。如果省略，则使用内部字符编码。</p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.mb-convert-case-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   按 <code class="parameter">mode</code> 指定的模式转换 <code class="parameter">string</code> 大小写后的版本。
  </p>
 </div>


 <div class="refsect1 unicode" id="refsect1-function.mb-convert-case-unicode">
  <h3 class="title">Unicode</h3>
  <p class="para">
   和类似 <span class="function"><a href="strtolower.html" class="function">strtolower()</a></span>、<span class="function"><a href="strtoupper.html" class="function">strtoupper()</a></span> 的标准大小写转换函数相比，
   大小写转换的执行根据 Unicode 字符属性的基础。
   因此此函数的行为不受语言环境（locale）设置的影响，能够转换任意具有“字母”属性的字符，例如元音变音A（Ä）。
  </p>
  <p class="para">
   更多关于 Unicode 属性的信息，请查看 <a href="http://www.unicode.org/unicode/reports/tr21/" class="link external">&raquo;&nbsp;http://www.unicode.org/unicode/reports/tr21/</a>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mb-convert-case-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3172">
    <p><strong>Example #1 <span class="function"><strong>mb_convert_case()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"mary&nbsp;had&nbsp;a&nbsp;Little&nbsp;lamb&nbsp;and&nbsp;she&nbsp;loved&nbsp;it&nbsp;so"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mb_convert_case</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MB_CASE_UPPER</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;输出&nbsp;MARY&nbsp;HAD&nbsp;A&nbsp;LITTLE&nbsp;LAMB&nbsp;AND&nbsp;SHE&nbsp;LOVED&nbsp;IT&nbsp;SO<br /></span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mb_convert_case</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MB_CASE_TITLE</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;输出&nbsp;Mary&nbsp;Had&nbsp;A&nbsp;Little&nbsp;Lamb&nbsp;And&nbsp;She&nbsp;Loved&nbsp;It&nbsp;So<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>

  <p class="para">
   <div class="example" id="example-3173">
    <p><strong>Example #2 非拉丁 UTF-8 文本的<span class="function"><strong>mb_convert_case()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Τάχιστη&nbsp;αλώπηξ&nbsp;βαφής&nbsp;ψημένη&nbsp;γη,&nbsp;δρασκελίζει&nbsp;υπέρ&nbsp;νωθρού&nbsp;κυνός"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mb_convert_case</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MB_CASE_UPPER</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;输出&nbsp;ΤΆΧΙΣΤΗ&nbsp;ΑΛΏΠΗΞ&nbsp;ΒΑΦΉΣ&nbsp;ΨΗΜΈΝΗ&nbsp;ΓΗ,&nbsp;ΔΡΑΣΚΕΛΊΖΕΙ&nbsp;ΥΠΈΡ&nbsp;ΝΩΘΡΟΎ&nbsp;ΚΥΝΌΣ<br /></span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mb_convert_case</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">MB_CASE_TITLE</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;输出&nbsp;Τάχιστη&nbsp;Αλώπηξ&nbsp;Βαφήσ&nbsp;Ψημένη&nbsp;Γη,&nbsp;Δρασκελίζει&nbsp;Υπέρ&nbsp;Νωθρού&nbsp;Κυνόσ<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mb-convert-case-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="mb_strtolower.html" class="function" rel="rdfs-seeAlso">mb_strtolower()</a> - 使字符串小写</span></li>
    <li class="member"><span class="function"><a href="mb_strtoupper.html" class="function" rel="rdfs-seeAlso">mb_strtoupper()</a> - 使字符串大写</span></li>
    <li class="member"><span class="function"><a href="strtolower.html" class="function" rel="rdfs-seeAlso">strtolower()</a> - 将字符串转化为小写</span></li>
    <li class="member"><span class="function"><a href="strtoupper.html" class="function" rel="rdfs-seeAlso">strtoupper()</a> - 将字符串转化为大写</span></li>
    <li class="member"><span class="function"><a href="ucfirst.html" class="function" rel="rdfs-seeAlso">ucfirst()</a> - 将字符串的首字母转换为大写</span></li>
    <li class="member"><span class="function"><a href="ucwords.html" class="function" rel="rdfs-seeAlso">ucwords()</a> - 将字符串中每个单词的首字母转换为大写</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>